package com.leyou.item.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.leyou.item.entity.Brand;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@SuppressWarnings("ALL")
/**
 * @Description :
 * @author     :LD
 */
public interface BrandMapper extends BaseMapper<Brand> {

    @Select("select b.* from tb_brand b,tb_category_brand cb where b.id=cb.brand_id and cb.category_id=#{cid}")
    List<Brand> findBrandByCategoryId(Long cid);

    @Insert("insert into tb_category_brand values(#{cid},#{bid})")
    void saveCategoryBrand(@Param("cid") Long cid, @Param("bid") Long bid);

    @Delete("delete from tb_category_brand where brand_id=#{id}")
    void deleteByBid(Long id);
}
